package com.huijutao;

import android.support.v4.app.FragmentTransaction;
import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import android.support.v7.widget.Toolbar;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.RadioGroup;

import com.huijutao.beans.GroupItem;
import com.huijutao.shoucangfragment.FMFindShouCang;
import com.huijutao.shoucangfragment.FMGroupShouCang;

import java.util.List;


public class ShouCangActivity extends ActionBarActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_shoucang);
        Toolbar toobar= (Toolbar) findViewById(R.id.toolbar);
        setSupportActionBar(toobar);
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);
        RadioGroup radioGroup= (RadioGroup) findViewById(R.id.shoucang_radiogroup);
        FragmentTransaction ft0 = getSupportFragmentManager().beginTransaction();
        FMFindShouCang fmFindShouCang = new FMFindShouCang();
        ft0.replace(R.id.shoucang_container, fmFindShouCang);
        ft0.commit();
        radioGroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {

            private List<GroupItem> groupItems;

            @Override
            public void onCheckedChanged(RadioGroup group, int checkedId) {
                switch (checkedId){
                    case R.id.shoucang_radiobutton1:
                        FragmentTransaction ft1 = getSupportFragmentManager().beginTransaction();
                        FMFindShouCang fmFindShouCang = new FMFindShouCang();
                        ft1.replace(R.id.shoucang_container, fmFindShouCang);
                        ft1.commit();
                        break;
                    case R.id.shoucang_radiobutton2:
                        FragmentTransaction ft2 = getSupportFragmentManager().beginTransaction();
                        FMGroupShouCang fmGroupShouCang = new FMGroupShouCang();
                        ft2.replace(R.id.shoucang_container, fmGroupShouCang);
                        ft2.commit();
                        break;
                }
            }
        });
    }

}
